home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / www / src / WWW / Library / Implementation / tcp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-09  |  13.9 KB  |  542 lines

  1. /*                                                      System dependencies in the W3 library
  2.                                    SYSTEM DEPENDENCIES
  3.                                              
  4.    System-system differences for TCP include files and macros. This file includes for each
  5.    system the files necessary for network and file I/O.
  6.    
  7.   AUTHORS
  8.   
  9.   TBL                     Tim Berners-Lee, W3 project, CERN, <timbl@info.cern.ch>
  10.                          
  11.   EvA                     Eelco van Asperen <evas@cs.few.eur.nl>
  12.                          
  13.   MA                      Marc Andreesen NCSA
  14.                          
  15.   AT                      Aleksandar Totic <atotic@ncsa.uiuc.edu>
  16.                          
  17.   SCW                     Susan C. Weber <sweber@kyle.eitech.com>
  18.                          
  19.   HISTORY:
  20.   
  21.   22 Feb 91               Written (TBL) as part of the WWW library.
  22.                          
  23.   16 Jan 92               PC code from EvA
  24.                          
  25.   22 Apr 93               Merged diffs bits from xmosaic release
  26.                          
  27.   29 Apr 93               Windows/NT code from SCW
  28.                          
  29.  */
  30.  
  31. #ifndef TCP_H
  32. #define TCP_H
  33.  
  34. /*
  35.  
  36. Default values
  37.  
  38.    These values may be reset and altered by system-specific sections later on.  there are
  39.    also a bunch of defaults at the end .
  40.    
  41.  */
  42. /* Default values of those: */
  43. #define NETCLOSE close      /* Routine to close a TCP-IP socket         */
  44. #define NETREAD  read       /* Routine to read from a TCP-IP socket     */
  45. #define NETWRITE write      /* Routine to write to a TCP-IP socket      */
  46.  
  47. /* Unless stated otherwise, */
  48. #define SELECT                  /* Can handle >1 channel.               */
  49. #define GOT_SYSTEM              /* Can call shell with string           */
  50.  
  51. #ifdef unix
  52. #define GOT_PIPE
  53. #endif
  54. #ifdef VM
  55. #define GOT_PIPE                /* Of sorts */
  56. #endif
  57.  
  58. #ifdef DECNET
  59. typedef struct sockaddr_dn SockA;  /* See netdnet/dn.h or custom vms.h */
  60. #else /* Internet */
  61. typedef struct sockaddr_in SockA;  /* See netinet/in.h */
  62. #endif
  63.  
  64.  
  65. /*
  66.  
  67. Macintosh - Think-C
  68.  
  69.    Think-C is one development environment on the Mac.
  70.    
  71.    We recommend that you compile with 4-byte ints to be compatible with MPW C.  We used
  72.    Tom Milligan's s_socket library which was written for 4 byte int, and the MacTCP
  73.    library assumes 4-byte int.
  74.    
  75.  */
  76. #ifdef THINK_C
  77. #undef GOT_SYSTEM
  78. #define DEBUG                   /* Can't put it on the CC command line  */
  79. #define NO_UNIX_IO              /* getuid() missing                     */
  80. #define NO_GETPID               /* getpid() does not exist              */
  81. #define NO_GETWD                /* getwd() does not exist               */
  82.  
  83. #undef NETCLOSE             /* Routine to close a TCP-IP socket         */
  84. #undef NETREAD              /* Routine to read from a TCP-IP socket     */
  85. #undef NETWRITE             /* Routine to write to a TCP-IP socket      */
  86. #define NETCLOSE s_close    /* Routine to close a TCP-IP socket         */
  87. #define NETREAD  s_read     /* Routine to read from a TCP-IP socket     */
  88. #define NETWRITE s_write    /* Routine to write to a TCP-IP socket      */
  89.  
  90. #define bind s_bind         /* Funny names presumably to prevent clashes */
  91. #define connect s_connect
  92. #define accept s_accept
  93. #define listen s_listen
  94. #define socket s_socket
  95. #define getsockname s_getsockname
  96.  
  97. /* The function prototype checking is better than the include files
  98. */
  99.  
  100. extern s_close(int s);
  101. extern s_read(int s, char *buffer, int buflen);
  102. extern s_write(int s, const char *buffer, int buflen);
  103.  
  104. extern bind(int s, struct sockaddr *name, int namelen);
  105. extern accept(int s, struct sockaddr *addr, int *addrlen);
  106. extern listen(int s, int qlen);
  107. extern connect(int s, struct sockaddr *addr, int addrlen);
  108.  
  109. extern s_socket(int domain, int type, int protocol);
  110. extern s_getsockname(int s, struct sockaddr *name, int *namelen);
  111. extern struct hostent *gethostent(const char * name);
  112. extern unsigned long inet_addr(const char * name);
  113.  
  114. #endif /* THINK_C */
  115.  
  116.  
  117. /*
  118.  
  119. Macintosh - MPW
  120.  
  121.    MPW is one development environment on the Mac.
  122.    
  123.    This entry was created by Aleksandar Totic (atotic@ncsa.uiuc.edu) this file is
  124.    compatible with sockets package released by NCSA.  One major conflict is that this
  125.    library redefines write/read/etc as macros.  In some of HTML code these macros get
  126.    executed when they should not be. Such files should define NO_SOCKET_DEFS on top. This
  127.    is a temporary hack.
  128.    
  129.  */
  130. #ifdef applec                   /* MPW  */
  131. #undef GOT_SYSTEM
  132. #define DEBUG                   /* Can't put it on the CC command line */
  133. #define NO_UNIX_IO              /* getuid() missing
  134. */
  135. #define NO_GETPID               /* getpid() does not exist
  136. */
  137. #define NO_GETWD                /* getwd() does not exist
  138. */
  139.  
  140. #undef NETCLOSE             /* Routine to close a TCP-IP socket */
  141. #undef NETREAD              /* Routine to read from a TCP-IP socket */
  142. #undef NETWRITE             /* Routine to write to a TCP-IP socket */
  143. #define NETCLOSE s_close    /* Routine to close a TCP-IP socket */
  144. #define NETREAD  s_read     /* Routine to read from a TCP-IP socket */
  145. #define NETWRITE s_write    /* Routine to write to a TCP-IP socket */
  146. #define _ANSI_SOURCE
  147. #define GUI
  148. #define LINEFEED 10
  149. #define ANON_FTP_HOSTNAME
  150. #ifndef NO_SOCKET_DEFS
  151. #include <MacSockDefs.h>
  152. #endif
  153.  
  154. #include <socket.ext.h>
  155. #include <string.h>
  156.  
  157. #endif                 /* MPW */
  158.  
  159.  
  160.  
  161. #ifndef STDIO_H
  162. #include <stdio.h>
  163. #define STDIO_H
  164. #endif
  165.  
  166. /*
  167.  
  168. Big Blue - the world of incompatibility
  169.  
  170. IBM RS600
  171.  
  172.    On the IBM RS-6000, AIX is almost Unix.
  173.    
  174.  */
  175. #ifdef _AIX
  176. #define AIX
  177. #endif
  178. #ifdef AIX
  179. #define unix
  180. #endif
  181.  
  182. /*    AIX 3.2
  183. **    -------
  184. */
  185.  
  186. #ifdef _IBMR2
  187. #define USE_DIRENT              /* sys V style directory open */
  188. #endif
  189.  
  190.  
  191. /*
  192.  
  193. IBM VM-CMS, VM-XA Mainframes
  194.  
  195.    MVS is compiled as for VM. MVS has no unix-style I/O.  The command line compile options
  196.    seem to come across in lower case.
  197.    
  198.  */
  199. #ifdef mvs
  200. #define MVS
  201. #endif
  202.  
  203. #ifdef MVS
  204. #define VM
  205. #endif
  206.  
  207. #ifdef NEWLIB
  208. #pragma linkage(newlib,OS)      /* Enables recursive NEWLIB */
  209. #endif
  210.  
  211. /*      VM doesn't have a built-in predefined token, so we cheat: */
  212. #ifndef VM
  213. #include <string.h>             /* For bzero etc - not  VM */
  214. #endif
  215.  
  216. /*      Note:   All include file names must have 8 chars max (+".h")
  217. **
  218. **      Under VM, compile with "(DEF=VM,SHORT_NAMES,DEBUG)"
  219. **
  220. **      Under MVS, compile with "NOMAR DEF(MVS)" to get rid of 72 char margin
  221. **        System include files TCPIP and COMMMAC neeed line number removal(!)
  222. */
  223.  
  224. #ifdef VM                       /* or MVS -- see above. */
  225. #define NOT_ASCII               /* char type is not ASCII */
  226. #define NO_UNIX_IO              /* Unix I/O routines are not supported */
  227. #define NO_GETPID               /* getpid() does not exist */
  228. #define NO_GETWD                /* getwd() does not exist */
  229. #ifndef SHORT_NAMES
  230. #define SHORT_NAMES             /* 8 character uniqueness for globals */
  231. #endif
  232. #include <manifest.h>
  233. #include <bsdtypes.h>
  234. #include <stdefs.h>
  235. #include <socket.h>
  236. #include <in.h>
  237. #include <inet.h>
  238. #include <netdb.h>
  239. #include <errno.h>          /* independent */
  240. extern char asciitoebcdic[], ebcdictoascii[];
  241. #define TOASCII(c)   (c=='\n' ?  10  : ebcdictoascii[c])
  242. #define FROMASCII(c) (c== 10  ? '\n' : asciitoebcdic[c])
  243.  
  244. #include <bsdtime.h>
  245. #include <time.h>
  246. #include <string.h>
  247. #define INCLUDES_DONE
  248. #define TCP_INCLUDES_DONE
  249. #endif
  250.  
  251.  
  252. /*
  253.  
  254. IBM-PC running MS-DOS with SunNFS for TCP/IP
  255.  
  256.    This code thanks to Eelco van Asperen <evas@cs.few.eur.nl>
  257.    
  258.  */
  259. #ifdef PCNFS
  260. #include <sys/types.h>
  261. #include <string.h>
  262. #include <errno.h>          /* independent */
  263. #include <sys/time.h>       /* independent */
  264. #include <sys/stat.h>
  265. #include <fcntl.h>          /* In place of sys/param and sys/file */
  266. #define INCLUDES_DONE
  267. #define FD_SET(fd,pmask) (*(unsigned*)(pmask)) |=  (1<<(fd))
  268. #define FD_CLR(fd,pmask) (*(unsigned*)(pmask)) &= ~(1<<(fd))
  269. #define FD_ZERO(pmask)   (*(unsigned*)(pmask))=0
  270. #define FD_ISSET(fd,pmask) (*(unsigned*)(pmask) & (1<<(fd)))
  271. #endif  /* PCNFS */
  272.  
  273. /*
  274.  
  275. IBM-PC running Windows NT
  276.  
  277.    These parameters providede by  Susan C. Weber <sweber@kyle.eitech.com>.
  278.    
  279.  */
  280. #ifdef _WINDOWS
  281. #include "fcntl.h"                      /* For HTFile.c */
  282. #include "sys\types.h"                  /* For HTFile.c */
  283. #include "sys\stat.h"                   /* For HTFile.c */
  284.  
  285. #undef NETREAD
  286. #undef NETWRITE
  287. #undef NETCLOSE
  288. #define NETREAD(s,b,l)  ((s)>10 ? recv((s),(b),(l),0) : read((s),(b),(l)))
  289. #define NETWRITE(s,b,l) ((s)>10 ? send((s),(b),(l),0) : write((s),(b),(l)))
  290. #define NETCLOSE(s)     ((s)>10 ? closesocket(s) : close(s))
  291. #include <io.h>
  292. #include <string.h>
  293. #include <process.h>
  294. #include <time.h>
  295. #include <direct.h>
  296. #include <stdio.h>
  297. #include <winsock.h>
  298. typedef struct sockaddr_in SockA;  /* See netinet/in.h */
  299. #define INCLUDES_DONE
  300. #define TCP_INCLUDES_DONE
  301. #endif  /* WINDOWS */
  302.  
  303.  
  304.  
  305. /*
  306.  
  307. VAX/VMS
  308.  
  309.    Under VMS, there are many versions of TCP-IP. Define one if you do not use Digital's
  310.    UCX product:
  311.    
  312.   UCX                     DEC's "Ultrix connection" (default)
  313.                          
  314.   WIN_TCP                 From Wollongong, now GEC software.
  315.                          
  316.   MULTINET                From SRI, now from TGV Inv.
  317.                          
  318.   DECNET                  Cern's TCP socket emulation over DECnet
  319.                          
  320.    The last three do not interfere with the unix i/o library, and so they need special
  321.    calls to read, write and close sockets. In these cases the socket number is a VMS
  322.    channel number, so we make the @@@ HORRIBLE @@@ assumption that a channel number will
  323.    be greater than 10 but a unix file descriptor less than 10.  It works.
  324.    
  325.  */
  326. #ifdef vms
  327. /*
  328.  
  329.    #define CACHE_FILE_PREFIX  "SYS$LOGIN:Z_"
  330.    
  331.  */
  332. #ifdef WIN_TCP
  333. #undef NETREAD
  334. #undef NETWRITE
  335. #undef NETCLOSE
  336. #define NETREAD(s,b,l)  ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
  337. #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
  338. #define NETCLOSE(s)     ((s)>10 ? netclose(s) : close(s))
  339. #endif
  340.  
  341. #ifdef MULTINET
  342. #undef NETCLOSE
  343. #undef NETREAD
  344. #undef NETWRITE
  345. #define NETREAD(s,b,l)  ((s)>10 ? socket_read((s),(b),(l)) : read((s),(b),(l)))
  346. #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : \
  347.                                 write((s),(b),(l)))
  348. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  349. #endif
  350.  
  351. #ifdef DECNET
  352. #undef SELECT  /* not supported */
  353. #undef NETREAD
  354. #undef NETWRITE
  355. #undef NETCLOSE
  356. #define NETREAD(s,b,l)  ((s)>10 ? recv((s),(b),(l),0) : read((s),(b),(l)))
  357. #define NETWRITE(s,b,l) ((s)>10 ? send((s),(b),(l),0) : write((s),(b),(l)))
  358. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  359. #endif /* Decnet */
  360.  
  361. /*      Certainly this works for UCX and Multinet; not tried for Wollongong
  362. */
  363. #ifdef MULTINET
  364. #include "multinet_root:[multinet.include.sys]types.h"
  365. #include "multinet_root:[multinet.include]errno.h"
  366. #include "multinet_root:[multinet.include.sys]time.h"
  367. #else
  368. #include types
  369. #include errno
  370. #include time
  371. #endif /* multinet */
  372.  
  373. #include string
  374.  
  375. #ifndef STDIO_H
  376. #include stdio
  377. #define STDIO_H
  378. #endif
  379.  
  380. #include file
  381.  
  382. #ifndef DECNET  /* Why is it used at all ? Types conflict with "types.h" */
  383. #include unixio
  384. #endif
  385.  
  386. #define INCLUDES_DONE
  387.  
  388. #ifdef MULTINET  /* Include from standard Multinet directories */
  389. #include "multinet_root:[multinet.include.sys]socket.h"
  390. #ifdef __TIME_LOADED  /* defined by sys$library:time.h */
  391. #define __TIME  /* to avoid double definitions in next file */
  392. #endif
  393. #include "multinet_root:[multinet.include.netinet]in.h"
  394. #include "multinet_root:[multinet.include.arpa]inet.h"
  395. #include "multinet_root:[multinet.include]netdb.h"
  396.  
  397. #else  /* not multinet */
  398. #ifdef DECNET
  399. #include "types.h"  /* for socket.h */
  400. #include "socket.h"
  401. #include "dn"
  402. #include "dnetdb"
  403. /* #include "vms.h" */
  404.  
  405. #else /* UCX or WIN */
  406. #include socket
  407. #include in
  408. #include inet
  409. #include netdb
  410.  
  411. #endif  /* not DECNET */
  412. #endif  /* of Multinet or other TCP includes */
  413.  
  414. #define TCP_INCLUDES_DONE
  415.  
  416. #endif  /* vms */
  417.  
  418.  
  419.  
  420. /*
  421.  
  422. SCO ODT unix version
  423.  
  424.  */
  425.  
  426. #ifdef sco
  427. #include <sys/fcntl.h>
  428. #define USE_DIRENT
  429. #endif
  430.  
  431. /*
  432.  
  433. MIPS unix
  434.  
  435.  */
  436. /* Mips hack (bsd4.3/sysV mixture...) */
  437.  
  438. #ifdef mips
  439. extern int errno;
  440. #endif
  441.  
  442.  
  443. /*
  444.  
  445. Regular BSD unix versions
  446.  
  447.    These are a default unix where not already defined specifically.
  448.    
  449.  */
  450. #ifndef INCLUDES_DONE
  451. #include <sys/types.h>
  452. /* #include <streams/streams.h>                 not ultrix */
  453. #include <string.h>
  454.  
  455. #include <errno.h>          /* independent */
  456. #include <sys/time.h>       /* independent */
  457. #include <sys/stat.h>
  458. #include <sys/param.h>
  459. #include <sys/file.h>       /* For open() etc */
  460. #define INCLUDES_DONE
  461. #endif  /* Normal includes */
  462.  
  463. /*                      Directory reading stuff - BSD or SYS V
  464. */
  465. #ifdef unix                    /* if this is to compile on a UNIX machine */
  466. #define GOT_READ_DIR 1    /* if directory reading functions are available */
  467. #ifdef USE_DIRENT             /* sys v version */
  468. #include <dirent.h>
  469. #define direct dirent
  470. #else
  471. #include <sys/dir.h>
  472. #endif
  473. #if defined(sun) && defined(__svr4__)
  474. #include <sys/fcntl.h>
  475. #include <limits.h>
  476. #endif
  477. #endif
  478.  
  479. /*
  480.  
  481. Defaults
  482.  
  483.   INCLUDE FILES FOR TCP
  484.   
  485.  */
  486. #ifndef TCP_INCLUDES_DONE
  487. #include <sys/socket.h>
  488. #include <netinet/in.h>
  489. #ifndef __hpux /* this may or may not be good -marc */
  490. #include <arpa/inet.h>      /* Must be after netinet/in.h */
  491. #endif
  492. #include <netdb.h>
  493. #endif  /* TCP includes */
  494.  
  495.  
  496. /*
  497.  
  498.   MACROS FOR MANIPULATING MASKS FOR SELECT()
  499.   
  500.  */
  501. #ifdef SELECT
  502. #ifndef FD_SET
  503. typedef unsigned int fd_set;
  504. #define FD_SET(fd,pmask) (*(pmask)) |=  (1<<(fd))
  505. #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
  506. #define FD_ZERO(pmask)   (*(pmask))=0
  507. #define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
  508. #endif  /* FD_SET */
  509. #endif  /* SELECT */
  510.  
  511. /*
  512.  
  513.   M ACROS FOR CONVERTING CHARACTERS
  514.   
  515.  */
  516. #ifndef TOASCII
  517. #define TOASCII(c) (c)
  518. #define FROMASCII(c) (c)
  519. #endif
  520.  
  521. /*
  522.  
  523.   CACHE FILE PREFIX
  524.   
  525.    This is something onto which we tag something meaningful to make a cache file name.
  526.    used in HTWSRC.c at least. If it is nor defined at all, caching is turned off.
  527.    
  528.  */
  529. #ifndef CACHE_FILE_PREFIX
  530. #ifdef unix
  531. #define CACHE_FILE_PREFIX  "/usr/wsrc/"
  532. #endif
  533. #endif
  534.  
  535. #endif /* TCP_H */
  536.  
  537.  
  538.  
  539. /*
  540.  
  541.    end of system-specific file  */
  542.